<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      //   // 1.setInterval
      document.title = 0;
      //   setInterval(function () {
      //     document.title++;
      //   }, 1000);
      //   //2.settimeout
      //   function fn() {
      //     setTimeout(function () {
      //       document.title++;
      //       fn();
      //     }, 1000);
      //   }
      // 3.动画帧 requestAnimationFrame
      var num = 0;
      function fn() {
        num++;
        if (num % 20 == 0) {
          document.title++;
        }
        window.requestAnimationFrame(fn);
      }

      fn();
    </script>
  </body>
</html>
